﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ZhimeiSoft.Framework.Client.Base;
using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.Framework.Client.Utils;
using ZhimeiSoft.CharmManager.Client.Manager;
using ZhimeiSoft.CharmManager.Client.Interface;

namespace ZhimeiSoft.CharmManager.Client.Forms
{
    public partial class frmAdjustReservationServiceItem : FormBase
    {
        private DBEntityReservation reservationInfo;
        private DBEntityCustomInfo customInfo = new DBEntityCustomInfo();
        public DateTime AdjustDateTime
        {
            get
            {
                DateTime resultDate = new DateTime(reservationEndDate.Value.Year, reservationEndDate.Value.Month, reservationEndDate.Value.Day,
                reservationEndHour.CurrDateTime.Hour, reservationEndHour.CurrDateTime.Minute, reservationEndHour.CurrDateTime.Second);
                return resultDate;
            }
        }
        public frmAdjustReservationServiceItem(DataRow drInfo, DBEntityReservation reservation, DBEntityCustomInfo custom)
        {
            InitializeComponent();
            reservationInfo = reservation;
            customInfo = custom;
            reservationStartDate.Value = reservation.RESERVATIONTIME;
            reservationStartHour.CurrDateTime = reservation.RESERVATIONTIME;

            reservationEndDate.Value = DateTime.Now;
            reservationEndHour.CurrDateTime = DateTime.Now;
            labServiceCode.Text = "项目编码：" + drInfo[DBEntityServiceItem.FieldName.SERVICEITEMCODE].ToString();
            labServiceName.Text = "项目名称：" + drInfo[DBEntityServiceItem.FieldName.SNAME].ToString();
            labServiceLastNbr.Text = "剩余次数：" + drInfo[DBEntityCustomerServiceItem.FieldName.CREMAINCOUNT].ToString();
        }

        private void buttonX3_Click(object sender, EventArgs e)
        {
            frmCustomReservationMonth frmCustom = new frmCustomReservationMonth();
            frmCustom.QueryReservation(reservationInfo.RESERVATIONTIME, customInfo);
            frmCustom.ShowDialog();
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            DateTime resultDate = new DateTime(reservationEndDate.Value.Year, reservationEndDate.Value.Month, reservationEndDate.Value.Day,
                reservationEndHour.CurrDateTime.Hour, reservationEndHour.CurrDateTime.Minute, reservationEndHour.CurrDateTime.Second);

            int resultTime = reservationEndDate.Value.Year * 10000 + reservationEndDate.Value.Month * 100 + reservationEndDate.Value.Day;
            int nowTime = DateTime.Now.Year * 10000 + DateTime.Now.Month * 100 + DateTime.Now.Day;
            if (resultTime < nowTime)
            {
                MsgBox.MsgInfo("要调整的预约时间必须大于当前的时间。");
                return;
            }
            this.DialogResult = DialogResult.OK;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
